<html>
<head>
<#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
<#include "/WEB-INF/views/template/bootMainCss.ftl" parse=true encoding="utf-8">
    <link href="${basePath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/css/form.lzy.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <style>
        .row{ margin: 0;}
        .cash-info-tip{margin-right: 10px;}
        .search{ float: left;}
        .shop-img{ text-align: left; padding-left: 30px;}
        .shop-img img{ float: left; margin-right: 10px;}
        .shop-img span{ display: block;}
        .name{ text-align: left; padding-left: 30px;}
        .name span{ display: block;}
        #tbodyId{ font-size: 13px;}
        #myTable thead{ font-size: 14px;}
        #startTime form-control{width: 100%;}
        .form_datetime{ float: left; width: 240px; margin-right: 10px;}
    </style>
</head>
<body>
<input type="hidden" id="pack_page" value="1">
<div class="panel panel-lzy">
    <div class="panel-body">
        <h5 class="tips-lzy">操作提示</h5>
        <ul class="tips-list-lzy">
            <li>◆&nbsp;<span>该页面显示了该业务员每天的相关统计。</span></li>
        </ul>
    </div>
</div>
<!--支付信息-->
<div class="panel-body row">
    <div class="cash-info-tip">
        <span>总销售额:<b id="totalSale"><#if voDto??>${voDto.totalSale!}<#else>0</#if>
        </b>元</span>
    </div>
    <div class="cash-info-tip">
        <span>总收益:<b id="totalProfit"><#if voDto??>${voDto.totalProfit!}<#else>0</#if></b>元</span>
    </div>
    <div class="cash-info-tip">
        <span>查询收益:<b id="queryProfit">0.00</b>元</span>
    </div>
</div>

<div class="panel-body row">
    <form id="myForm" class="form-margin-right">
        <input type="hidden" id="userId" name="userId" value="${voDto.userId?c}"/>
        <div id="start_visit_time" class="input-group date form_datetime">
            <span class="input-group-addon">开始日期</span>
            <input id="startDate" name="startDate" class="form-control" size="16" type="text" value="" readonly>
            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
        </div>
        <div id="end_visit_time" class="input-group date form_datetime">
            <span class="input-group-addon">结束日期</span>
            <input id="endDate" name="endDate" class="form-control" size="16" type="text" value="" readonly>
            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
        </div>
        <button type="button" class="btn btn-primary btn-sm" onclick="search(1)">查询</button>
    </form>
</div>

<!-- 分页查询的地址-->
<div class="panel-body panel-white">
    <div class="table-responsive">
        <table id="myTable"
               class="table table-hover"
               data-url="${basePath}/admin/statistics/personalProfit/json"
               data-pageSize="10,50,100" data-method="GET">
            <thead>
            <!-- 需要循环的字段  对应mapper文件-->
            <tr>
                <th  data-type="xuhao" width="15%">编号</th>
                <th  data-field="date" width ="20%">时间</th>
                <th  data-field="count" width ="20%">完成订单</th>
                <th  data-field="profit" data-call="true" width ="20%">收益</th>
                <th  data-field="button" data-call="true">操作</th>
            </tr>
            </thead>
            <tbody id="tbodyId">

            </tbody>
        </table>
    </div>
    <!-- 分页条-->
    <div class="row">
        <div align="left" class="col-xs-6">
            <div class="input-group">
                <span class="input-group-addon" id="pageCount"></span> <select
                    id="pageSize" onchange="search(1)" class="form-control"
                    style="width: 100px"></select>
            </div>
        </div>
        <div align="right" class="col-xs-6">
            <ul class="pagination" id="pagination"></ul>
        </div>
    </div>
</div>

</div>
<#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
<script type="text/javascript" src="${basePath}/bootstrap/js/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/myPage.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
    //结束日期大于开始日期
    $(function() {
        $("#depart-box label input").each(function () {
            if (idArr.indexOf(parseInt($(this).val())) != "-1") {
                $(this).prop("checked", true)
            }
        })

        $('#start_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            //startDate: new Date(),
            autoclose: true //选择日期后自动关闭
        }).on("changeDate", function () {
            $("#end_visit_time").datetimepicker("setStartDate", $("#startDate").val());
        });
        $('#end_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            //startDate: new Date(),
            autoclose: true //选择日期后自动关闭
        });
    })
    //查询收益额
    function tableCallBack(data, id) {
            if (id == 'button') {//增加操作按钮
                var count = 0;
                var _button = '<button type="button" name="' + data.date + '" class="btn btn-white btn-xs" onclick="viewMeal(this);">查看 </button> ';
                return _button;
            }
            else {
                if(data[id] == null || data[id] == ''){
                    return '';
                }else{
                    return data[id];
                }
            }

    }
    //详情
    function viewMeal(obj){
        var date = obj.name;
        window.location.href='${basePath}/admin/statistics/personalRecordListPage?userId=${voDto.userId?c}&date='+ date;
    }

    //导出
    function exportOrder(id){
        layer.confirm('是否确定此操作？', {
            btn: ['确定','取消'] //按钮
        }, function() {
            $.ajax({
                type: 'POST',
                url: '${basePath}/trip/disable',
                data:{id :id},
                dataType: 'json',
                success: function (data) {

                    layer.alert('禁用成功!', {
                        icon: 6
                    }, function(index){
                        layer.closeAll('dialog');
                        search(parseInt($('.active').attr('jp-data')));
                    });
                }
            });
        });
    }

    function packValue(data) {
        var queryProfit = data.queryProfit;
        $("#queryProfit").text(queryProfit);
    }
</script>
</body>
</html>